<form #myForm="ngForm" (ngSubmit)="onSubmit(myForm.value, myForm.valid)" novalidate>
  <div>
    <label>用户名：</label>
    <input type="text" ngModel required name="username" minlength="6" (input)="onMobileInput(myForm)">
    <div [hidden]="mobileValid || mobileUntouched">
      <div [hidden]="!myForm.form.hasError('required','username')">
        用户名是必填项
      </div>
      <div [hidden]="!myForm.form.hasError('minlength','username')">
        最小长度6
      </div>
    </div>
  </div>
  <div>
    <label>手机号：</label>
    <input type="number" ngModel mobile name="mobile">
    <div [hidden]="!myForm.form.hasError('mobile','mobile')">
      请输入正确的手机号！
    </div>
  </div>
  <div ngModelGroup="passwordsGroup" equals>
    <div>
      <label>密码：</label>
      <input type="password" minlength="6" ngModel name="password">
      <div [hidden]="!myForm.form.hasError('minlength',['passwordsGroup','password'])">
        密码最小长度为6位
      </div>
    </div>
    <div>
      <label>确认密码：</label>
      <input type="password" ngModel name="pconfirm">
      <div [hidden]="!myForm.form.hasError('equal','passwordsGroup')">
        {{myForm.form.getError('equal','passwordsGroup')?.desc}}
      </div>
    </div>
  </div>
  <div>
    <button type="submit">注册</button>
  </div>
</form>
